home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / Technology demos / Mirror / mirror.dba < prev    next >
Encoding:
Text File  |  2001-01-30  |  4.0 KB  |  115 lines

  1. remstart
  2.       __   __           ______             __
  3.    __/ /_ / /__  _____ / ____/_____ _____ / /__  _____
  4.   /_  __// __  // _  // / __ / _  // ___// // / /    /
  5.    / /  / / / //  __// /_/ //  __// /__ / _  / / // /_
  6.   /_/  /_/ /_//____//_____//____//____//_/ \_\/____/  \
  7.     /                                                 /
  8.     \       Mirror  Technology Demo                   \
  9.     /       Version 1.00 - 27th January 2001          /
  10.     \                                                 \
  11.     /       Author:  Rob Moran [theGecko]             /
  12.     \       Web:     http://www.gecko.f2s.com         \
  13.     /       E-Mail:  gecko@f2s.com                    /
  14.     \       AIM:     Rob M0RAN                        \
  15.     /       ICQ#:    105558276                        /
  16.     \                                                 \
  17.     /_________________________________________________/
  18.  
  19. remend
  20.  
  21. `------------------------------------------------------SETUP------------------------------------------------------
  22.  
  23. set display mode 800,600,16
  24. autocam off
  25. hide mouse
  26. sync on
  27. backdrop on
  28. color backdrop rgb(0,0,0)
  29. anglex1# = -90.0
  30. anglex2# = -87.0
  31. angley2# = 175.0
  32. cameraspeed# = 50.0
  33.  
  34. `-----------images
  35.  
  36. load image "map1.bmp",101
  37. load image "map2.bmp",102
  38. load image "text1.bmp", 103
  39.  
  40. `convert image to sprite to make it see-through
  41. sprite 1,0,0,103
  42.  
  43. `-----------models
  44.  
  45. `load in the same object twice
  46. load object "can.x",201
  47. load object "can.x",202
  48. load object "can2.x",203
  49.  
  50. load object "wall.3ds",205
  51. load object "frame.3ds",206
  52. load object "glass.3ds",207
  53.  
  54. `position objects
  55. position object 201,0,0,-100
  56. position object 202,0,0,-100
  57. position object 203,0,0,100
  58. position object 206,0,0,-1
  59.  
  60. `scale one object slightly smaller than the other so that their textures don't interfere
  61. scale object 202, 99, 99, 99
  62.  
  63. `replace the texture of the 'larger' object with the reflection map and make it 'ghostly'
  64. texture object 201, 101
  65. texture object 207, 102
  66. ghost object on 201
  67. ghost object on 207
  68.  
  69. position camera 100.0, 100.0, -200
  70. point camera 0, 0, -50
  71.  
  72. `----------------------------------------------------MAIN LOOP----------------------------------------------------
  73.  
  74. do
  75.    `get any mouse movements
  76.    movex# = mousemovex()
  77.    movey# = mousemovey()
  78.  
  79.    if mouseclick()=1
  80.       `move round when mouse buttons pressed
  81.       if camera position x() + movex# < -200 then movex# = 0.0
  82.       if camera position x() + movex# > 200 then movex# = 0.0
  83.       if camera position y() - movey# > 200 then movey# = 0.0
  84.       if camera position y() - movey# < -200 then movey# = 0.0
  85.  
  86.       position camera newxvalue(camera position x(),movex#,cameraspeed#), newyvalue(camera position y(),movey#,cameraspeed#), -200.0
  87.       scroll object texture 207, 0.0-(movey#*0.0055), (movex#*0.00275)
  88.       point camera 0, 0, -50
  89.    else
  90.       anglex1#=wrapvalue(anglex1#-movey#)
  91.       angley1#=wrapvalue(angley1#-movex#)
  92.       anglex2#=wrapvalue(anglex2#+movey#)
  93.       angley2#=wrapvalue(angley2#+movex#)
  94.  
  95.       `rotate both objects at the same time
  96.       rotate object 201, anglex1#, 0.0, angley1#
  97.       rotate object 202, anglex1#, 0.0, angley1#
  98.       rotate object 203, anglex2#, 0.0, angley2#
  99.  
  100.       `this is the funky bit - move the texture offset of the reflection map in the opposite
  101.       `direction as the mouse moves, thus keeping the texture facing the camera
  102.       `the current angle must be tested to counteract the texture scrolling the wrong way
  103.       if anglex1# > 180 & anglex1# < 360
  104.          scroll object texture 201, (movex#*0.00275), (movey#*0.0055)
  105.       else
  106.          scroll object texture 201, (movex#*0.00275), 0.0-(movey#*0.0055)
  107.       endif
  108.             `                                   ^--------------------^------- these numbers work for
  109.             `                                                                 any model/texture
  110.    endif
  111.    sync
  112. loop
  113.  
  114. `------------------------------------------------------END--------------------------------------------------------
  115.